#23 new
Deleted User

Use Cucumber Features instead of RSpec Stories

Reported by Deleted User | October 25th, 2008 @ 07:11 AM

Since Cucumber is going to (eventually) replace RSpec's story running, it would probably be a good idea to generate Cucumber Features instead of RSpec Stories.

Comments and changes to this ticket

  • Bryan

    Bryan January 11th, 2009 @ 09:41 PM

    I've got a fork that generates Cucumber features instead of RSpec stories available Here

    I didn't add or remove any functionality, just moved the stories over and made them work as features.

  • Randy Harmon

    Randy Harmon February 15th, 2009 @ 03:07 PM

    Bryan, did you test by running only rake features? Or also with autospec and/or running cucumber features directly? I'm finding the latter cases failing, though running under rake works great.

    When not in Rake, I get all the code in ra_env.rb complaining about the classes not being loaded (ApplicationController and Fixtures).

  • Bryan

    Bryan February 16th, 2009 @ 07:48 PM

    Randy,

    I typically don't run cucumber with autospec, it seems better suited to RSpec.

    I just ran "cucumber features" and autospec over the features, both with no errors.

    I am using cucumber version 0.1.16, Rails 2.2.2, ZenTest 3.11.1, Ruby 1.8.6 patchlevel 111.

    I don't know if that particular combo is what's doing it for me.

    Bryan

  • John Small

    John Small March 2nd, 2009 @ 04:30 AM

    I'm obviously doing something wrong. I downloaded the forked project, created a bare Rails app (2.2.2) ran the usual script/generate authenticated user Sessions --aasm --rspec, then tried rake features and it all went pear shaped.

    After putting in place the things that were missing, a route to '/' and a application view with a

    I'm still getting errors.

    What else needs to be in place from a bare installation to get these features to run without errors?

    Other people are doing this without a problem. Is it my setup? I'm using Rspec & Rspec rails as gems 1.1.12, and Cucumber as a gem 0.1.16.

  • John Small

    John Small March 2nd, 2009 @ 09:56 AM

    OK, I think I've sorted out what's going on. It seems that the latest version of restful-authentication with aasm doesn't allow a user to log in unless they've been activated. So the generators have to take note of the "--aasm" or "--stateful" or "--include-activation" and then add an extra step to activate a new account before it can log in.

    There're a couple of other areas where the features don't match the current behaviour of RA, so places where it says "And Oona should be logged in" has to change to "And Oona should not be logged in", because Oona is an unactivated user and can't log in.

    Also I'll question the extra lines on the "Scenario: Anonymous user can not create an account with bad email". It does extra stuff to create a new user after the verification that a user can't be created with a bad email. The extra stuff goes ahead and puts a correct email in and creates a new user and then fails when testing that login has been succesful because Oona can't log in.

    It looks like it's been copied in from "Scenario: Anonymous user can create an account" because it follows the exact same steps after it gets the error message about the bad email.

    Do you want to edit it or shall I fork it and edit it myself?

  • Bryan

    Bryan March 2nd, 2009 @ 10:30 AM

    John,

    sounds like you have a good contribution to make and are all over it ... I say have at it!

    I've been looking at the rest-auth features in the fbrp project. The feature specs are written in a declarative manner making them easier (I think) to understand. Maybe these would be a better way to go?

  • John Small

    John Small March 2nd, 2009 @ 11:12 AM

    The only awkward bit I can see is the business of responding to --aasm and so on. As the feature generator currently stands it just does a one size fits all set of scenarios. To get it to respond appropriately to user input the template would probably need to be in erb format. Which is not a small change from what is there now. I'll look at it later on this week when I've got some more time.

  • Sam Pierson

    Sam Pierson April 13th, 2009 @ 03:29 PM

    Randy, Did you ever get your NameError solved? I too am getting "uninitialized constant ApplicationController" Figure out what it was? Thanks, -Sam.

  • Sam Pierson

    Sam Pierson April 13th, 2009 @ 08:40 PM

    Nevermind - I am too new too cucumber. I figured it out.

  • JasonFB

    JasonFB June 24th, 2009 @ 04:30 PM

    Sam, Did you ever get your NameError solved? I am new to cucumber too, I installed restful_authentication and it came with two .feature files and a bunch of step_definitions, looking like this in my features folder:

    features/
    accounts.feature sessions.feature step_definitions/

    ra_env.rb
    ra_navigation_steps.rb
    ra_resource_steps.rb
    ra_response_steps.rb
    rest_auth_features_helper.rb
    user_steps.rb
    

    When I run them, I'm getting

    $ cucumber features uninitialized constant ApplicationController (NameError)
    ./features/step_definitions/ra_env.rb:15 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:inpolyglot_original_require' /Library/Ruby/Gems/1.8/gems/polyglot-0.2.6/lib/polyglot.rb:55:in require' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:95:inrequire_files' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:104:in each_lib' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:102:ineach' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:102:in each_lib' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:95:inrequire_files' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:47:in execute!' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/../lib/cucumber/cli/main.rb:25:inexecute' /Library/Ruby/Gems/1.8/gems/cucumber-0.3.11/bin/cucumber:9 /usr/bin/cucumber:19:in load' /usr/bin/cucumber:19

    Did I miss something trivial?

  • JasonFB

    JasonFB June 24th, 2009 @ 04:31 PM

    sorry, that text I pasted of the folder structure didn't come out too well :(

  • Sam Pierson

    Sam Pierson June 24th, 2009 @ 05:32 PM

    Yup. It was a while ago but as I recall I just reran "script/generate cucumber" and they world was a happier place.

  • JasonFB

    JasonFB June 24th, 2009 @ 09:56 PM

    I see.

    Yes, thanks. That error has gone away for me.

    Now cucumber is having some problems with what's in these restful_authentication tests. Like I said, I didn't write these, I think they appeared here when I installed restful_authentication? (does that make sense?) That's what I'm guessing. Note: I installed cucumber after I installed restful_authentication, but ran "script/generate cucumber" in the process of getting cucumber setup. So really I'm just running cucumber for the first time on these restful_authentication tests and they are failing out of the box, wonder if anyone else is seeing this.

    $ cucumber features/profile.feature Multiple step definitions have the same Regexp:

    features/step_definitions/user_steps.rb:16:in /^(.*) (.*) user named '(.*)'$/'<br/> features/step_definitions/user_steps.rb:29:in/^there is no (.) user named '(.)'$/'

    user_steps.rb, line 16:

    Given "$an $user_type user named '$login'" do |_, user_type, login|
    create_user! user_type, named_user(login) end

    user_steps.rb, line 29:

    Given "there is no $user_type user named '$login'" do |_, login|
    @user = User.find_by_login(login) @user.destroy! if @user @user.should be_nil end

  • Sam Pierson

    Sam Pierson June 25th, 2009 @ 12:36 AM

    I seem to recall some of the restful_authentication feature specs being broken, or at least not working if you didn't use the default options. If you're interested I ended up fixing them as part of some work I did on it in my github branch: git://github.com/ombwa/restful-authentication.git (I added options for --haml and --email-only).
    -Sam.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Restful Authentication Generator

This widely-used plugin provides a foundation for securely managing user
authentication:
* Login / logout
* Secure password handling
* Account activation by validating email
* Account approval / disabling by admin
* Rudimentary hooks for authorization and access control.

http://github.com/technoweenie/restful-authentication/tree

Pages